home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / mint / mntlb20 / lib / _fltsisf.cpp < prev    next >
Text File  |  1992-04-26  |  1KB  |  59 lines

  1. |
  2. | long integer to single float conversion routine
  3. |
  4. | Andreas Schwab (schwab@ls5.informatik.uni-dortmund.de)
  5. |  mostly copied from _floatsi.cpp
  6.  
  7. #ifndef __M68881__
  8.  
  9. #ifdef    sfp004
  10.  
  11. | addresses of the 68881 data port. This choice is fastest when much data is
  12. | transferred between the two processors.
  13.  
  14. comm =     -6    |    fpu command reg
  15. resp =    -16    |    fpu response reg
  16. zahl =      0    |    fpu data reg
  17.  
  18.     .text
  19.     .even
  20.     .globl    ___floatsisf
  21.  
  22. ___floatsisf:
  23.     lea    0xfffa50,a0
  24.     movew    #0x4000,a0@(comm)    | load long int to fp0
  25.     cmpiw    #0x8900,a0@(resp)    | check
  26.     movel    a7@(4),a0@
  27.     movew    #0x7400,a0@(comm)    | get double from fp0
  28. | wait loop is NOT coded directly
  29. 1:    cmpw    #0x8900,a0@(resp)
  30.     beq    1b
  31.     movel    a0@,d0
  32.     rts
  33.  
  34. #else /* !sfp004 */
  35.  
  36. BIAS4    =    0x7F-1
  37.  
  38.     .text
  39.     .even
  40.     .globl    ___floatsisf
  41.  
  42. ___floatsisf:
  43.     moveml    d2-d5,sp@-    | save registers to make norm_sf happy
  44.  
  45.     movel    sp@(20),d4    | prepare result mantissa
  46.     movew    #BIAS4+32-8,d0    | radix point after 32 bits
  47.     movel    d4,d2        | set sign flag
  48.     swap    d2
  49.     tstw    d2        | check sign of number
  50.     bge    1f        | nonnegative
  51.     negl    d4        | take absolute value
  52. 1:
  53.     clrw    d1        | set rounding = 0
  54.     jmp    norm_sf
  55.  
  56. #endif /* !sfp004 */
  57.  
  58. #endif /* !__M68881__ */
  59.